package com.qf.fronted.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qf.fronted.domain.HeaderGoods;
import com.qf.fronted.mapper.HeaderGoodsMapper;
import com.qf.fronted.service.IHeaderGoodsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Date: 2020/9/22 9:54
 * @Author: 何泽富
 * @Description :
 */
@Service
public class HeaderGoodsServiceImpl implements IHeaderGoodsService {
    private HeaderGoodsMapper headerGoodsMapperImpl;

    public HeaderGoodsServiceImpl(HeaderGoodsMapper headerGoodsMapperImpl) {
        this.headerGoodsMapperImpl = headerGoodsMapperImpl;
    }

    private final String imageServerLocation = "http://localhost/images/header/";

    @Override
    public List<HeaderGoods> getSrcImage() {
        List<HeaderGoods> list = headerGoodsMapperImpl.selectList(Wrappers.emptyWrapper());
        // 是将图片设置为可直接访问的地址
        list.forEach(g -> {
            String imageSrc = g.getSrcImage(); // header/huawei.jpg
            g.setSrcImage(imageServerLocation + imageSrc);
        });
        return list;
    }
}
